package belf.migrate.engine.admin.taskconf;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SourceConf {
    @JsonProperty("catalog")
    private String catalogName;
    @JsonProperty("database")
    private String databaseName;
    @JsonProperty("schema")
    private String schemaName;
    /** 是否大小写敏感 */
    @JsonProperty("caseSensitive")
    private boolean caseSensitive;
    @JsonProperty("connection")
    private ConnectionConf connectionConf;

    @JsonProperty("taskMode")
    private String taskMode;

    private String tableName;
    private String[] tables;

    private String sql;

    @JsonProperty("fieldCase")
    private String fieldCase;

    @JsonProperty("quote")
    private boolean quote;

    public String toJson() throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writer().writeValueAsString(this);
    }
}
